package struts2.action;

import java.util.Map;

//import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import DAO.DaoLogin;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
	private String username;
	private String password;
	
	public String execute() {
		String role = DaoLogin.checkLogin(username, password);
		if (role!=null) {
//			HttpSession ss=ServletActionContext.getRequest().getSession();
//			ss.setAttribute("username", username);
//			ss.setAttribute("role", role);
			return "success";
		} else {
			addActionError(getText("error.login"));
			return "error";
		}
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}
